// 2. 封装自定义函数，将查询字符解析成对象，将对象解析成查询字符
const obj = {user:'战三',password:'2133ss',viplv:'5'}
const query = 'user=ln&password=134www&viplv=0'
function parser(str_or_obj){
    if(typeof str_or_obj == 'string'){
        let obj = {}
        // str_or_obj.replace('=',':').split('&')
        str_or_obj.split('&').forEach(val=>{
            obj[val.split('=')[0]] = val.split('=')[1]
        })
        return obj
    }
    if(str_or_obj instanceof Object){
        let str = ''
        for(let i in str_or_obj){
            str += `${i}=${str_or_obj[i]}&`
        }
        str = str.slice(0,-1)
        return str
    }
}
console.log(parser(query))